<script setup lang="ts">
import { PureTableBar } from "@/components/RePureTableBar";
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
import { status } from "nprogress";
import { ref, reactive } from "vue";
import View from "@iconify-icons/ep/view";
import AddFill from "@iconify-icons/ri/add-circle-line";

import { useDeliver } from "./utils/hook";

/** 搜索区DOM */
const formRef = ref(null);
/** 表格DOM */
const tableRef = ref();

const { dataList, columns, loading, onSearch, openDialog } =
  useDeliver(tableRef);
</script>

<template>
  <div>
    <div class="container mx-auto">
      <!-- 用户搜索表单 -->
      <!-- <el-form
        ref="formRef"
        :inline="true"
        :model="manageSearch"
        class="search-form bg-bg_color px-8 pt-[12px]"
      >
        <el-form-item label="模糊搜素：" prop="key">
          <el-input
            v-model="manageSearch.key"
            placeholder="请输入礼品名称或描述"
            clearable
            class="!w-[220px]"
          />
        </el-form-item>
        <el-form-item label="发货方式：" prop="shippingid">
          <el-select
            v-model="manageSearch.shippingid"
            placeholder="请选择"
            clearable
            class="!w-[180px]"
          >
            <el-option
              v-for="(item, index) in shoppingidList"
              :key="index"
              :label="item.name"
              :value="item.shippingid"
            />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button
            type="primary"
            :icon="useRenderIcon('ri:search-line')"
            @click="onSearch"
          >
            搜索
          </el-button>
          <el-button :icon="useRenderIcon(Refresh)" @click="resetForm(formRef)">
            重置
          </el-button>
        </el-form-item>
      </el-form> -->

      <PureTableBar
        title="礼品发货管理"
        :columns="columns"
        @refresh="onSearch()"
      >
        <!-- 表头右侧按钮 -->
        <template #buttons>
          <el-button type="primary" :icon="useRenderIcon(AddFill)">
            新增礼品
          </el-button>
        </template>

        <!-- dynamicColumns 动态列 -->
        <template v-slot="{ size, dynamicColumns }">
          <!-- 表格内容区域 -->
          <pure-table
            ref="tableRef"
            row-key="id"
            :loading="loading"
            adaptive
            :size="size"
            :adaptiveConfig="{ offsetBottom: 108 }"
            align-whole="center"
            table-layout="auto"
            :data="dataList"
            :columns="dynamicColumns"
            :header-cell-style="{
              background: 'var(--el-fill-color-light)',
              color: 'var(--el-text-color-primary)'
            }"
          >
            <template #operation="{ row }">
              <el-button
                type="primary"
                link
                :icon="useRenderIcon(View)"
                @click="openDialog('查看收货信息', row)"
              >
                查看
              </el-button>
            </template>
          </pure-table>
        </template>
      </PureTableBar>
    </div>
  </div>
</template>
